<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2022/5/23
 * Time: 15:58
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\pay\middleware;

use app\common\lib\Show;
use app\common\lib\Status;
use Htlove\Jwt;
use think\facade\Log;

class Auth
{
    public function handle($request, \Closure $next)
    {
        $param = $request->param();
        if (empty($param)) {
            return Show::json_show(Status::status_error,"参数不存在");
        }
        if(empty($param['sign'])){
            return Show::json_show(Status::status_error,"参数不存在");
        }
        $check = Jwt::getInstance()->verifyToken($param['sign']);

        if($check === false){
            return Show::json_show(Status::status_error,"验证失败");
        }
        $request->sData = $check;
        return $next($request);
    }
}